<?php
    include APPLICATION_PATH . '/application/views/head.phtml';
    include APPLICATION_PATH . '/application/views/top.phtml';
    include APPLICATION_PATH . '/application/views/left.phtml';
?>

		<!-- END SIDEBAR -->



		<!-- BEGIN PAGE -->
<script src="../../../public/ckeditor/ckeditor.js"></script>
	<script src="../../../public/ckeditor/samples/js/sample.js"></script>
	<link rel="stylesheet" href="../../../public/ckeditor/samples/css/samples.css">
	<link rel="stylesheet" href="../../../public/ckeditor/samples/toolbarconfigurator/lib/codemirror/neo.css">
	<!--<script src="/public/pagejs/article_edit1.js"></script>-->

	<script src="/public/js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script>
  $(document).ready(function() {
	$('#close_form').click(function() {
		window.location = "/Article/list";
	});
	$('#submit_form').click(function() {

		var type = $('#article_type').data('id');
		//var source = $('#article_source').data('source');
		var status = $('#article_status').data('status');
		//alert(type);
		//alert(source);
		//alert(status);

		var __editForm = $('#form_article_edit');
		var oEditor = CKEDITOR.instances.editor;
		var contentEditor = oEditor.getData();
		var objArtiForm = {
			__formId: $("input[name='art_id']", __editForm),
			__formTitle: $("input[name='art_title']", __editForm),
			__formType: $("select[name='art_type']", __editForm),
			__formAuthor: $("input[name='art_author']", __editForm),
			__formSource: $("input[name='art_source']", __editForm),
			__formStatu: $("select[name='art_statu']", __editForm)

		}
		$.ajax({
			type: "POST",
			url: "/Article/edit/id/" + objArtiForm.__formId.val(),
			data: {
				//"article_id" : objArtiForm.__formId.val(),
				"title": objArtiForm.__formTitle.val(),
				"article_type_id": type,
				"author": objArtiForm.__formAuthor.val(),
				"source":objArtiForm.__formSource.val(),
				"status": status,
				"content": contentEditor

			},
			success: function(data) {

				layer.alert(data.info, function() {
					if (true === data.status) window.location = "/Article/list";
				});
			}
		});
		return false;

	});
})

</script>
		<div class="page-content">
 <div id="thispage" data-id="31"></div>

			<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<div id="portlet-config" class="modal hide">

				<div class="modal-header">

					<button data-dismiss="modal" class="close" type="button"></button>

					<h3>portlet Settings</h3>

				</div>

				<div class="modal-body">

					<p>Here will be a configuration form</p>

				</div>

			</div>

			<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->

			<!-- BEGIN PAGE CONTAINER-->        

			<div class="container-fluid">

				<!-- BEGIN PAGE HEADER-->

				<div class="row-fluid">

					<div class="span12">

						<!-- BEGIN STYLE CUSTOMIZER -->

						<div class="color-panel hidden-phone">

							<!-- <div class="color-mode-icons icon-color"></div> -->

							<div class="color-mode-icons icon-color-close"></div>

							<div class="color-mode">

								<p>THEME COLOR</p>

								<ul class="inline">

									<li class="color-black current color-default" data-style="default"></li>

									<li class="color-blue" data-style="blue"></li>

									<li class="color-brown" data-style="brown"></li>

									<li class="color-purple" data-style="purple"></li>

									<li class="color-grey" data-style="grey"></li>

									<li class="color-white color-light" data-style="light"></li>

								</ul>

								<label>

									<span>Layout</span>

									<select class="layout-option m-wrap small">

										<option value="fluid" selected>Fluid</option>

										<option value="boxed">Boxed</option>

									</select>

								</label>

								<label>

									<span>Header</span>

									<select class="header-option m-wrap small">

										<option value="fixed" selected>Fixed</option>

										<option value="default">Default</option>

									</select>

								</label>

								<label>

									<span>Sidebar</span>

									<select class="sidebar-option m-wrap small">

										<option value="fixed">Fixed</option>

										<option value="default" selected>Default</option>

									</select>

								</label>

								<label>

									<span>Footer</span>

									<select class="footer-option m-wrap small">

										<option value="fixed">Fixed</option>

										<option value="default" selected>Default</option>

									</select>

								</label>

							</div>

						</div>

						<!-- END BEGIN STYLE CUSTOMIZER -->  

						<!-- BEGIN PAGE TITLE & BREADCRUMB-->

						<h3 class="page-title">

							文章列表

						</h3>

						<ul class="breadcrumb">

							<li>

								<i class="icon-home"></i>
								<span>当前位置：</span>
								<span>首页</span>

								<i class="icon-angle-right"></i>

							</li>

							<li>

								<span>文章管理</span>

								<i class="icon-angle-right"></i>

							</li>

							<li><span>文章列表</span> <i class="icon-angle-right"></i></li>
							</li>

							<li><span>文章修改</span></li>

						</ul>

						<!-- END PAGE TITLE & BREADCRUMB-->

					</div>

				</div>

				<!-- END PAGE HEADER-->

				<!-- BEGIN PAGE CONTENT-->

				<div class="row-fluid">

					<div class="span6 responsive" data-tablet="span12 fix-offset" data-desktop="span6" style="width:100%;">

						<!-- BEGIN EXAMPLE TABLE PORTLET-->

						<div class="portlet box grey">

							<div class="portlet-title">

								<div class="caption"><i class="icon-user"></i>文章编辑</div>

								<div class="actions controls">

								</div>

							</div>
							<div class="portlet-body">

							<form action="#" id="form_article_edit" method="post">
								<table width="800px" height="700px" style="margin:auto;">
									<thead>
									<tr><td><input name="art_id" type="hidden" value="<?php echo $articleInfo[0]['article_id']; ?>"></td></tr>
									<tr><th>文章标题</th><td><input name="art_title" type="text" value="<?php echo $articleInfo[0]['title']; ?>"></td></tr>
										<tr><th>文章类型</th><td>
											<?php
												foreach($typicalName as $k=>$v){
													if($v['article_type_id'] == $articleInfo[0]['article_type_id']){
														$name       .= $v['name'];
														$article_id .= $v['article_type_id'];
													}								
													} 
													echo <<< EOF
													<input type="text"  readonly="readonly"  value="{$name}" data-id="{$article_id}" id="article_type"/>	
EOF;
											?>
									<tr><th>频道</th><td><input name="art_channel" readonly="readonly" type="text" value="<?php echo $articleInfo[0]['chanel']; ?>"></td>														
 									<tr><th>作者</th><td><input name="art_author" type="text" value="<?php echo $articleInfo[0]['author']; ?>"></td></tr>
										<tr><th>文章来源</th><td>
											<input name="art_source" type="text" value="<?php echo $articleInfo[0]['source'];
											?>"  id="article_source" readonly="readonly">
											</td></tr>
										<tr><th>文章状态</th><td>
											<?php 
											if($articleInfo[0]["status"] == 1){
												$articleInfo[0]["status"] = "推送失败";
												$status .= 1;
											}
											else if($articleInfo[0]["status"] == 2){
												$articleInfo[0]["status"] = "已推送";
												$status .= 2;
											}
											else if($articleInfo[0]["status"] == 0){
												$articleInfo[0]["status"] = "未推送";
												$status .= 0;
											}
											echo <<< EOF
													<input name="art_source" type="text" value="{$articleInfo[0]["status"]}" data-status="{$status}" id="article_status" readonly="readonly">
EOF;
												?>
																					
										</td></tr>
										<tr><th>文章内容</th><td><tetxarea id="editor" name="art_content" ><?php 

               $arr = array('[img]','[br][br][br][br]','[&emsp][&emsp][&emsp][&emsp]','[&amp]','[p][&emsp][&emsp][/p]','[p][img][text-align:center]','[div][img][text-align:center]','[&nbsp]','[&emsp]','[img]','[/img]','[p][text-align:center]','[&ldquo]','[&rdquo]','[pstyle','[&lt]','[&gt]','[tablealign="center"]');

			   $arr2 = array('[p][img]','','[&emsp][&emsp]','&','','<p style="text-align:center;"> <img src="','<div style="text-align:center"> <img src="','&nbsp','&emsp;','<p style="text-align:center;"><img src="','"> </>','[p style="text-align:center;"]','"','"','[p style','<','>','[table align="center"]');


										 $content=str_replace($arr, $arr2, $articleInfo[0]['content'], $i);
									      //var_dump($content);
                                         $arr3 = array('[', ']');
										 $arr4 = array('<', '>');
										 echo str_replace($arr3, $arr4, $content, $i);	//输出 Hxlly Wyrld yf PHP 
										  // var_dump($co);
										// echo $i;	
                                         ?>

										</textarea></td></tr>
										
										<tr align="right"><td colspan='2'><!-- <button class="btn" data-dismiss="modal" aria-hidden="true" id="close_form">关闭</button> -->
</td>
									</thead>



                </table>
                <div style="width:800px; margin: 0 auto; text-align:right;">
                										<input type="button" value="关闭" id="close_form" class="btn" data-dismiss="modal" aria-hidden="true"/>
										    <button class="btn green btn-primary" id="submit_form" data-dismiss="modal">提交</button>
										    </div>

		</form>

							</div>

						</div>
						
						
								


						<!-- END EXAMPLE TABLE PORTLET-->

					</div>

				</div>

				<!-- END PAGE CONTENT-->

			</div>

			<!-- END PAGE CONTAINER-->

		</div>
<script>
	initSample();
</script>
    <!-- END PAGE -->
<?php
    include APPLICATION_PATH . '/application/views/foot.phtml';
?>


